package comm.qingke.main;

import java.io.InputStream;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.qingke.dao.ClazzDao;
import com.qingke.pojos.Clazz;
import com.qingke.pojos.Student;
import com.qingke.pojos.Teacher;

public class Test {
	public static void main(String[] args) {
		String source = "mybatis-config.xml";
		InputStream inputstream = Test.class.getClassLoader().getResourceAsStream(source);
		SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(inputstream);
		SqlSession session = factory.openSession();
		
/*		StudentDao studentdao = session.getMapper(StudentDao.class);
		List<Student> list = studentdao.selectAll();*/
		
		
		Clazz clazz = new Clazz();
		clazz.setName("LCU");
		Teacher teacher = (Teacher)session.selectOne("com.qingke.dao.TeacherDao.selectById", 2);
		System.out.println(teacher);
		clazz.setTeacher(teacher);
		
		ClazzDao clazzDao = session.getMapper(ClazzDao.class);
		List<Clazz> list = clazzDao.selectFilter(clazz);
		for(Clazz c:list){
			System.out.println(c);
		}
		
		session.close();
	}
}
